#include "main/utils.h"
using namespace std;

bool isContinuous(vector<int> vec) {
  if (vec.empty())
    return false;

  sort(vec.begin(), vec.end());

  int num_of_zero = 0;
  for (int i = 0; i < vec.size() && vec[i] == 0; ++i) {
    ++num_of_zero;
  }
  for (int i = num_of_zero; i < vec.size() - 1; ++i) {
    if (vec[i] == vec[i + 1]) {
      return false;
    }
    int num_of_gap = vec[i + 1] - vec[i] - 1;
    if (num_of_gap > num_of_zero) {
      return false;
    }
    num_of_zero -= num_of_gap;
  }
  return true;
}

int main() {
  vector<int> vec1 = {1, 3, 2, 5, 4};
  cout << isContinuous(vec1) << " expected: 1" << endl;

  vec1 = {1, 3, 2, 6, 4};
  cout << isContinuous(vec1) << " expected: 0" << endl;

  vec1 = {0, 3, 2, 6, 4};
  cout << isContinuous(vec1) << " expected: 1" << endl;

  vec1 = {0, 3, 1, 6, 4};
  cout << isContinuous(vec1) << " expected: 0" << endl;

  vec1 = {1, 3, 0, 5, 0};
  cout << isContinuous(vec1) << " expected: 1" << endl;

  vec1 = {1, 3, 0, 7, 0};
  cout << isContinuous(vec1) << " expected: 0" << endl;

  vec1 = {1, 0, 0, 5, 0};
  cout << isContinuous(vec1) << " expected: 1" << endl;

  vec1 = {1, 0, 0, 7, 0};
  cout << isContinuous(vec1) << " expected: 0" << endl;

  vec1 = {3, 0, 0, 0, 0};
  cout << isContinuous(vec1) << " expected: 1" << endl;

  vec1 = {0, 0, 0, 0, 0};
  cout << isContinuous(vec1) << " expected: 1" << endl;

  vec1 = {1, 0, 0, 1, 0};
  cout << isContinuous(vec1) << " expected: 0" << endl;

  return 0;
}
